layui.use(['form', 'table', 'laydate'], function () {
    var form = layui.form;
    var $ = layui.$;
    var table = layui.table,
        laydate = layui.laydate;

    getLogData();

    function getLogData(params) {
        let where = {};
        if (params !== undefined) {
            where = params;
        }
        table.render({
            elem: '#dataTable'
            , url: '/logs/getOperateLogData'
            , contentType: "application/json"
            , height: 'full-110'
            , loading: true
            , size: 'sm'
            , method: 'post'
            , where: where
            , cellMinWidth: 50
            , cols: [
                [
                    {field: 'createTime', fixed: 'left', title: '时间', width: '120'}
                    , {field: 'userCode', fixed: 'left', title: '用户', width: '100'}
                    , {field: 'method', fixed: 'left', title: '类型', width: '50'}
                    , {field: 'requestType', fixed: 'left', title: '请求方式', width: '60'}
                    , {field: 'ip', title: 'IP地址', width: '100'}
                    , {field: 'uri', title: '请求页面', width: '200'}
                    , {field: 'paramData', title: '请求参数'}
                    , {field: 'httpStatusCode', title: '返回', width: '50'}
                    , {field: 'timeConsuming', title: '用时(ms)', width: '80'}
                    , {field: 'operatingSystem', title: '操作系统', width: '100'}
                    , {field: 'browser', title: '浏览器', width: '100'}
                    , {field: 'browserVersion', title: '浏览器版本', width: '100'}
                ]
            ]
            , page: true
            , limit: 50
        });
    }


    form.on('submit(search)', function (data) {
        getLogData(data.field);
        return false;
    });


    laydate.render({
        elem: '#stime'
        , type: 'datetime'
    });
    laydate.render({
        elem: '#etime'
        , type: 'datetime'
    });
});